home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_srgp.lha / srgp / examples / testpaint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  2.0 KB  |  82 lines

  1. #include "srgp.h"
  2. #include <stdio.h>
  3.  
  4. /* TEST OF LOCATOR SAMPLE MODE. */
  5.  
  6. /* Left button paints in red, middle in green, right in blue.
  7.    Multiple buttons lead to color mixing.
  8.  */
  9.  
  10.  
  11. #define DLM   deluxe_locator_measure
  12.  
  13. int
  14. LocatorMeasuresEqual(DLM first, DLM second)
  15.  
  16. {
  17. return (
  18.  
  19.     (first.position.x == second.position.x) && 
  20.     (first.position.y == second.position.y) &&
  21.  
  22.     (first.button_chord[0] == second.button_chord[0]) &&  
  23.      (first.button_chord[1] == second.button_chord[1]) &&  
  24.      (first.button_chord[2] == second.button_chord[2]) &&
  25.  
  26.          (first.modifier_chord[0] == second.modifier_chord[0]) &&  
  27.      (first.modifier_chord[1] == second.modifier_chord[1]) &&  
  28.      (first.modifier_chord[2] == second.modifier_chord[2]) 
  29.   );
  30. }
  31.  
  32. DLM
  33. WaitForAnyChange (DLM original)
  34. {
  35.    DLM    retval;
  36.  
  37.    SRGP_sampleDeluxeLocator(&retval);
  38.    while ( LocatorMeasuresEqual(original, retval) )
  39.       SRGP_sampleDeluxeLocator(&retval);
  40.  
  41.    return(retval);
  42. }
  43.  
  44. main()
  45. {
  46.    DLM locmeasure;
  47.    int col;
  48.  
  49.    SRGP_begin ("Painting application", 800,800,3,FALSE);
  50.  
  51.    SRGP_loadCommonColor (0, "black");
  52.    SRGP_loadCommonColor (1, "blue");
  53.    SRGP_loadCommonColor (2, "green");
  54.    SRGP_loadCommonColor (3, "cyan");
  55.    SRGP_loadCommonColor (4, "red");
  56.    SRGP_loadCommonColor (5, "magenta");
  57.    SRGP_loadCommonColor (6, "yellow");
  58.    SRGP_loadCommonColor (7, "white");
  59.  
  60.  
  61.    SRGP_setLocatorEchoType (CURSOR);
  62.    SRGP_setFillStyle(BITMAP_PATTERN_OPAQUE); 
  63.    SRGP_setLocatorButtonMask
  64.       (LEFT_BUTTON_MASK | MIDDLE_BUTTON_MASK | RIGHT_BUTTON_MASK);
  65.    SRGP_setInputMode(LOCATOR, SAMPLE);
  66.  
  67.    while (1) {
  68.       SRGP_sampleDeluxeLocator (&locmeasure);
  69.       col = 0;
  70.       if (locmeasure.button_chord[LEFT_BUTTON]==DOWN) col += 4;
  71.       if (locmeasure.button_chord[MIDDLE_BUTTON]==DOWN) col += 2;
  72.       if (locmeasure.button_chord[RIGHT_BUTTON]==DOWN) col += 1;
  73.       if (col > 0) {
  74.      SRGP_setColor (col); 
  75.      SRGP_setFillBitmapPattern (col); 
  76.      SRGP_fillRectangleCoord
  77.         (locmeasure.position.x-5, locmeasure.position.y-5,
  78.          locmeasure.position.x+5, locmeasure.position.y+5);
  79.       }
  80.    }
  81. }
  82.